//
//  XiuGaiMiMaViewController.m
//  JuBoCRM
//
//  Created by iMac on 2024/2/23.
//  Copyright © 2024 iningKe. All rights reserved.
//

#import "XiuGaiMiMaViewController.h"

@interface XiuGaiMiMaViewController ()


@property (weak, nonatomic) IBOutlet TPKeyboardAvoidingScrollView *mainScrollView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *topSpace;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomSpace;
@property (weak, nonatomic) IBOutlet UITextField *laoMiMaTf;
@property (weak, nonatomic) IBOutlet UITextField *xinMiMaTf;
@property (weak, nonatomic) IBOutlet UITextField *queRenTf;

@property (strong, nonatomic) IBOutletCollection(UITextField) NSArray *textFieldArray;
@end

@implementation XiuGaiMiMaViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    
    self.customNavBar.title = @"修改密码";
 
    _topSpace.constant = NavaBarHeight;
    
    _bottomSpace.constant = ScreenBottom+20;
    
    if (@available(iOS 11.0, *)) {
        self.mainScrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
    
}
- (IBAction)laoClicn:(UIButton *)sender {
    sender.selected = !sender.selected;
    _laoMiMaTf.secureTextEntry = !sender.selected;
}
- (IBAction)xinClick:(UIButton *)sender {
    sender.selected = !sender.selected;
    _xinMiMaTf.secureTextEntry = !sender.selected;
}
- (IBAction)queClick:(UIButton *)sender {
    sender.selected = !sender.selected;
    _queRenTf.secureTextEntry = !sender.selected;
}

//确定
- (IBAction)queDingClick:(UIButton *)sender {
    
    [self.view endEditing:YES];
    
    for (UITextField *tf in _textFieldArray) {
        if(tf.text.length == 0){
            [ZZPUtils showWarning:tf.placeholder];
            return;
        }
    }
    
    if(![_xinMiMaTf.text isEqualToString:_queRenTf.text]){
        [ZZPUtils showWarning:@"两次输入密码不一致"];
        return;
    }
    
    NSMutableDictionary *paraDic = [NSMutableDictionary dictionary];
    [paraDic setValue:_laoMiMaTf.text forKey:@"oldPwd"];
    [paraDic setValue:_xinMiMaTf.text forKey:@"newPwd"];
    [paraDic setValue:GetHandleString(USERINFO, @"userId") forKey:@"id"];

    [[ZZPRequest getWebUtil] postNetworkRequestURLString:@"/adminUser/updatePassword" andParas:paraDic andShowHud:YES andTransferGottenData:^(id info, NSError *error) {
        if(!error){
            [ZZPUtils showWarning:@"修改成功"];
            [self.navigationController popViewControllerAnimated:YES];
        }
    }];
    
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end


